//
//  UIImage+CQCellBundle.m
//  AppCommonUICollect
//
//  Created by ciyouzen on 2018/7/3.
//  Copyright © 2018年 dvlproad. All rights reserved.
//

#import "UIImage+CQCellBundle.h"
#import <CJBaseUIKit/UIImage+CJChangeColor.h>
#import <CJBaseUIKit/UIImage+CJTransformSize.h>
#import <CJBaseUIKit/UIImage+CJRotateAngle.h>

@implementation UIImage (CQCellBundle)

#pragma mark - 下一步按钮使用的箭头图片

/*
 *  默认的下一步按钮使用的箭头图片
 *
 *  @return 箭头图片
 */
+ (UIImage *)cell_nextArrowImage_default {
    UIColor *arrowColor = [UIColor colorWithRed:12/255.0 green:16/255.0 blue:27/255.0 alpha:1.0];// #0C101B
    return [UIImage cell_nextArrowImageWithColor:arrowColor size:CGSizeMake(22, 22)];
}

/*
 *  获取下一步按钮使用的箭头图片
 *
 *  @param arrowColor   箭头颜色(有时候会有不同的主题)
 *  @param size         图片大小
 *
 *  @return 箭头图片
 */
+ (UIImage *)cell_nextArrowImageWithColor:(UIColor *)arrowColor size:(CGSize)size {
    UIImage *nextArrowImage = [UIImage cqCellBundle_imageNamed:@"icon_go_black"]; // 采用的图片请使用清晰度高的，避免设置size大的时候导致模糊 icon_cell_go_black
    nextArrowImage = [nextArrowImage cj_imageWithTintColor:arrowColor];
    nextArrowImage = [nextArrowImage cj_transformImageToSize:size];
    
    return nextArrowImage;
}


#pragma mark - "添加"按钮使用的箭头图片
/*
 *  默认的"添加"按钮使用的箭头图片
 *
 *  @return 箭头图片
 */
+ (UIImage *)cell_addImage_default {
    UIImage *addImage = [UIImage cqCellBundle_imageNamed:@"icon_cell_add"];
    
    return addImage;
}

#pragma mark - 基础接口
+ (nullable UIImage *)cqCellBundle_imageNamed:(NSString *)name {
    if(name.length == 0) {
        return nil;
    }
    
    NSBundle *bundle = [NSBundle bundleForClass:NSClassFromString(@"UIImage+CQCellBundle")];//此处不能使用UIImage作为获取bundle的类
    if (bundle == nil) {
        return nil;
    }
    NSURL *url = [bundle URLForResource:@"CQCellBundle" withExtension:@"bundle"];
    if (url == nil) {
        return nil;
    }
    NSBundle *imageBundle = [NSBundle bundleWithURL:url];
    UIImage *image = [UIImage imageNamed:name inBundle:imageBundle compatibleWithTraitCollection:nil];
    return image;
}

@end
